package com.example.springbootrabbitmq.sender;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author ljw
 * @description
 * @date 2022/9/9 17:09
 */
@Service
public class Sender {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void send() {
        //通过 RabbitTemplate 的 convertAndSend 方法向队列 my-queue 发送消息
        rabbitTemplate.convertAndSend("my-queue", "来自 rabbitmq 的问候");
    }
}
